package com.hdl.school.utils;

import com.alibaba.fastjson.JSON;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.List;

/**
 * Created by Admin on 2016/10/28.
 */
public class HttpResponseUtil {

    public static final <T> List<T> checkResponse(String res,Class<T> clazz){
        try {
            JSONObject jsonObject=new JSONObject(res);
            if(jsonObject.getInt("code")==0){
                String data=jsonObject.getString("data");
                return JSON.parseArray(data,clazz);
            }
        } catch (JSONException e) {
            e.printStackTrace();

        }
        return null;
    }
}
